<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\AdminBankIcon
 *
 * @property int $id
 * @property string $first_word 银行卡首字母 demo：A
 * @property string $bank_name 银行卡名称
 * @property string $icon_oss_url 银行卡icon url
 * @property string $bin_num 银行卡号前六位数字
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereBankName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereBinNum($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereFirstWord($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereIconOssUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property int $single_limit 单笔限额
 * @property int $day_limit 单日限额
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereDayLimit($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\AdminBankIcon whereSingleLimit($value)
 * @property-read string $ali_oss_full_url
 */
class AdminBankIcon extends Model
{
    protected $fillable = ['first_word','bank_name','icon_oss_url','bin_num','single_limit','day_limit'];

    protected $appends = [
        'ali_oss_full_url'
    ];
    //

    public function getSingleLimitAttribute(){
        return $this->attributes['single_limit']/100;
    }

    public function setSingleLimitAttribute($value){
        $this->attributes['single_limit'] = $value*100;
    }

    public function getDayLimitAttribute(){
        return $this->attributes['day_limit']/100;
    }

    public function setDayLimitAttribute($value){
        $this->attributes['day_limit']= $value*100;
    }

    /**
     * 获取oss完整路径
     * @return string
     * @author luwei
     * @date 2019-01-16 17:07
     */
    public function getAliOssFullUrlAttribute(){
        return $this->attributes['icon_oss_url'] ? getOssUrl($this->attributes['icon_oss_url']) : '';
    }
}
